<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div class="pageContent">
	<form method="post" id="pointsToMoneyForm" action="${rootUrl}/member/points-to-money/${pointsToMoney.id}" class="pageForm requipointsToMoney-validate" onsubmit="return beforeSubmit(this);">
		<c:if test="${pointsToMoney.id != 0 && pointsToMoney.id != '' }"><input type="hidden" name="_method" value="put"></c:if>
		<input type="hidden" id="pointsToMoneyId" name="pointsToMoney.id" value="${pointsToMoney.id }">
		<input type="hidden" name="dealerLevel.id" value="${dealerLevel.id }">
		
		<div class="pageFormContent" layoutH="56">
			<p>
				<label style="width:140px;">积分兑换名称：</label>
				<input  name="pointsToMoney.name" type="text" class="required " size="30" value="${pointsToMoney.name}"/>
			</p>
				<p>
			  <label style="width:140px;">兑换等级:</label>
			 <select name="pointsToMoney.level">
			 		<c:forEach items="${dealerLevelList}" var="dealerLevel">
						<option value="${dealerLevel.level}" <c:if test="${pointsToMoney.level==dealerLevel.level }">selected="selected"</c:if>>${dealerLevel.name}</option>
					</c:forEach>
				</select>
			</p>
			<p>
				<label style="width:140px;">100积分兑换多少现金：</label>
			    <input name="thePercent" class="required digits" type="text" size="30" value="<fmt:formatNumber value="${pointsToMoney.percent/100}" pattern="0"/>" onfocus="if (value =='0'){value =''}"  
            		onblur="if (value ==''){value='0'}"/>
			</p>
			<p>
			  <label style="width:140px;">最少多少积分可以兑换：</label>
			  <input  name="pointsToMoney.points"  type="text" class="required digits" size="30" value="${pointsToMoney.points}"/>
			</p>
			<p>
				<label style="width:140px;">开始时间：</label>
				<input type="text" name="pointsToMoney.startTime" class="required date" readonly="readonly" size="30" dateFmt="yyyy-MM-dd HH:mm:ss" value="<fmt:formatDate value="${pointsToMoney.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" /><a class="inputDateButton" href="javascript:;">选择</a>
			</p>
			<p>
				<label style="width:140px;">结束时间：</label>
				<input type="text" id="endTime" name="pointsToMoney.endTime" class="required date" readonly="readonly" size="30" dateFmt="yyyy-MM-dd HH:mm:ss" value="<fmt:formatDate value="${pointsToMoney.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" /><a class="inputDateButton" href="javascript:;">选择</a>
			</p>
   		 </div>
    	<div class="formBar">
			<ul>
				<li><div id= "pointsToMoneyButton" ><div class="buttonContent"><button  onclick ="checkedEndTime()" type="button">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
    </form>
</div>
<script>
var myDate = new Date();
var currentTime = myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate()+" "+myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds();
var eTime=$("#endTime").val();
var result = (Date.parse(eTime) - Date.parse(currentTime)) / 3600 / 1000;
 $(function(){
	 if($("#pointsToMoneyId").val()==""){
	$("#pointsToMoneyButton").attr("class","buttonActive"); 
	 }else{
    if(result<0){
    	$("#pointsToMoneyButton").attr("class","buttonDisabled");
    }else if(result>=0){
    	$("#pointsToMoneyButton").attr("class","buttonActive");
    }}
}); 
function checkedEndTime(){
	if($("#pointsToMoneyId").val()==""||result>=0){
	$("#pointsToMoneyForm").submit();
	}
}
function beforeSubmit(obj){
	return validateCallback(obj, newDialogAjaxDone);
} 
</script>